package com.android.readcard.utils.djlm.DJLMReader3.reader;

import android.text.TextUtils;

/**
 * Created by Sabirjan on 2017/10/12.
 * DJLMReader.
 * 飞宏电子
 */

public class ErrorCode {

    public final static int ERROR_CODE1 = 1;//无法连接蓝牙
    public final static int ERROR_CODE2 = 2;//服务端获取IP失败
    public final static int ERROR_CODE3 = 3;//参数无效
    public final static int ERROR_CODE4 = 4;//图片解码失败
    public final static int ERROR_CODE5 = 5;//读卡失败
    public final static int ERROR_CODE6 = 6;//身份证数据解码失败
    public final static int ERROR_CODE7 = 7;//服务端中断连接
    public final static int ERROR_CODE8 = 8;//无法连接服务端
    public final static int ERROR_CODE9 = 9;//不是店家联盟阅读器
    public final static int ERROR_CODE10 = 10;//次手机无法使用店家联盟阅读器
    public final static int ERROR_CODE11 = 11;//初始化失败
    public final static int ERROR_CODE12 = 12;//身份证没有正确的放入感应区内
    public final static int ERROR_CODE13 = 13;//读卡超时
    public final static int ERROR_CODE14 = 14;//蓝牙写入数据失败，请重试！

    public static String getErrorMessage(int errorCode) {
        switch (errorCode) {
            case ERROR_CODE1:
                return "无法连接蓝牙";
            case ERROR_CODE2:
                return "服务端获取IP失败";
            case ERROR_CODE3:
                return "参数无效";
            case ERROR_CODE4:
                return "图片解码失败";
            case ERROR_CODE5:
                return "读卡失败";
            case ERROR_CODE6:
                return "身份证数据解码失败";
            case ERROR_CODE7:
                return "服务端中断连接";
            case ERROR_CODE8:
                return "无法连接服务端";
            case ERROR_CODE9:
                return "不是店家联盟阅读器";
            case ERROR_CODE10:
                return "次手机无法使用店家联盟阅读器";
            case ERROR_CODE11:
                return "初始化失败！";
            case ERROR_CODE12:
                return "身份证没有正确的放入感应区内";
            case ERROR_CODE13:
                return "读卡超时";
            case ERROR_CODE14: return "蓝牙写入数据失败，请重试！";

        }

        return "getErrorMessage未知错误";
    }

    public static String getMessage(String message) {

        if (TextUtils.isEmpty(message) || message.length() != 6 || !message.startsWith("0000")) {
            return "message1未知错误";
        }

        switch (message) {
            case "00009F":
                return "寻找居民身份证成功";
            case "000010":
                return "接受业务终端数据的校验和错误";
            case "000011":
                return "接受业务终端数据的长度错误";
            case "000021":
                return "接受业务终端的命令错误，包括命令中的各种数值和逻辑搭配错误";
            case "000023":
                return "越权操作";
            case "000024":
                return "无法识别的错误";
            case "000031":
                return "居民身份证认证SAM_A失败";
            case "000032":
                return "SAM_A认证居民身份证失败";
            case "000033":
                return "信息验证错误";
            case "000037":
                return "指纹信息验证错误";
            case "00003F":
                return "指纹信息长度错误";
            case "000040":
                return "无法识别的身份证卡类型";
            case "000041":
                return "读居民身份证操作失败";
            case "000047":
                return "取随机数失败";
            case "000060":
                return "SAM_A自检失败，不能接受命令";
            case "000066":
                return "SAM_A没有经过授权，无法使用";
            case "000080":
                return "寻找居民身份证失败";
            case "000081":
                return "选取居民身份证失败";
            case "000091":
                return "居民身份证上此项无内容";
            case "000088":
                return "沒有可用的解码服务器，请稍后再重试";

        }

        return "message2未知错误！";
    }


}
